

/*二手房数量统计-年份 *****/
function echarts_4(data) {
  // 基于准备好的dom，初始化echarts实例
  var myChart = echarts.init(document.getElementById('echart4'));
  x = [] ,y =[]
          for(var i = 10;i<data.length;i++){//分离横纵轴数据
                 x[i- 10] = String(data[i].years).substring(2)+'年';
                 y[i-10] =data[i].num;
             }


 


      option = {
          tooltip: {
              trigger: 'axis',
              axisPointer: {
                  type: 'shadow'
              }
          },
          legend: {
              // data: ['2017年', '2018年'],
              data: ['住房数量'],
              align: 'right',
              right: '40%',
              top: '0%',
              textStyle: {
                  color: "#fff",
                  fontSize: '16',

              },
              itemWidth: 16,
              itemHeight: 16,
              itemGap: 35
          },
          grid: {
              left: '0%',
              top: '40px',
              right: '0%',
              bottom: '2%',
              containLabel: true
          },
          xAxis: [{
              type: 'category',
              data: x,
              axisLine: {
                  show: true,
                  lineStyle: {
                      color: "rgba(255,255,255,.1)",
                      width: 1,
                      type: "solid"
                  },
              },

              axisTick: {
                  show: false,
              },
              axisLabel: {
                  interval: 0,
                  // rotate:50,
                  show: true,
                  splitNumber: 15,
                  textStyle: {
                      color: "rgba(255,255,255,.6)",
                      fontSize: '16',
                  },
              },
          }],
          yAxis: [{
              type: 'value',
              axisLabel: {
                  //formatter: '{value} %'
                  show: true,
                  textStyle: {
                      color: "rgba(255,255,255,.6)",
                      fontSize: '16',
                  },
              },
              axisTick: {
                  show: false,
              },
              axisLine: {
                  show: true,
                  lineStyle: {
                      color: "rgba(255,255,255,.1	)",
                      width: 1,
                      type: "solid"
                  },
              },
              splitLine: {
                  lineStyle: {
                      color: "rgba(255,255,255,.1)",
                  }
              }
          }],
          series: [{
              name: '房屋总数',
              type: 'bar',
              data: y,
              barWidth: '15', //柱子宽度
              // barGap: 1, //柱子之间间距
              itemStyle: {
                  normal: {
                      color: '#2f89cf',
                      opacity: 1,
                      barBorderRadius: 5,
                  }
              }
            
          }
          ]
      };


      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      window.addEventListener("resize", function () {
          myChart.resize();
      });

 
}
